package org.yankun.exam4j.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.yankun.exam4j.session.SessionManager;



@Controller("IndexController")
public class IndexController {
	
	@RequestMapping()
	public ModelAndView toIndex(HttpServletResponse response,HttpServletRequest request
			){
		return new ModelAndView("/login/login",null);
	}
	
	@RequestMapping("index.do")
	public String doLogout(HttpServletResponse response,HttpServletRequest request){
		HttpSession session = request.getSession(false);
		if(!SessionManager.isLogon(session)){
			return "redirect:/login.do";
		}
		
		return "redirect:/dashboard/index.do";
	}
}